home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pine / ccmd / cmcfm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-19  |  2.4 KB  |  94 lines

  1. /*
  2.  Author: Andrew Lowry
  3.  
  4.  Columbia University Center for Computing Activities, July 1986.
  5.  Copyright (C) 1986, 1987, Trustees of Columbia University in the City
  6.  of New York.  Permission is granted to any individual or institution
  7.  to use, copy, or redistribute this software so long as it is not sold
  8.  for profit, provided this copyright notice is retained.
  9. */
  10. /* cmcfm
  11. **
  12. ** Code to parse command confirmation.  We succeed iff the next
  13. ** character is a newline.  Action routines for other confirming
  14. ** characters (like carriage return or formfeed) should insert
  15. ** a newline character for confirmation.  There is no completion.
  16. ** Standard break table breaks on every character.   A successful
  17. ** parse does not destroy the atom buffer.
  18. **/
  19.  
  20. #define    CFMERR            /* confirm error table allocated here */
  21.  
  22. #include "ccmdlib.h"        /* get standard symbols */
  23. #include "cmfncs.h"        /* and internal symbols */
  24.  
  25. /* Forward declaration of handler routines */
  26.  
  27. int cfmprs(), cfmhlp(), cfmcplt();
  28.         
  29. #define cfmbrk    cmallbk        /* std break table breaks on everything */
  30.  
  31. ftspec ft_cfm = { cfmprs, cfmhlp, cfmcplt, FT_DFX, &cfmbrk };
  32.  
  33. /* cfmprs
  34. **
  35. ** Purpose:
  36. **   Attempt to parse a confirmation.  Succeeds if the first character
  37. **   is a newline.  Any other character causes failure.  Returns no
  38. **   value.  A successful parse turns off the CM_CFM flag, as a side-
  39. **   effect.
  40. **/
  41.  
  42. PASSEDSTATIC int
  43. cfmprs(text,textlen,fdbp,parselen,value)
  44. char *text;
  45. int textlen;
  46. fdb *fdbp;
  47. int *parselen;
  48. pval *value;
  49. {
  50.   if (textlen == 0)            /* nothing to parse... */
  51.     return(CMxINC);            /* incomplete */
  52.   else if ((*text & CC_CHR) == NEWLINE) { /* found a newline... */
  53.     *parselen = 1;            /* consume one char */
  54.     cmcsb._cmflg |= CM_NAC;        /* no copy to atom buffer */
  55.     cmcsb._cmflg &= ~CM_CFM;        /* no longer confirmed */
  56.     return(CMxOK);            /* and return success */
  57.   }
  58.   else
  59.     return(CFMxNOC);            /* anything else... error */
  60. }
  61.  
  62. /* cfmhlp
  63. **
  64. ** Purpose:
  65. **   Give standard help for a confirmation parse... always the same thing.
  66. **/
  67.  
  68. PASSEDSTATIC int
  69. cfmhlp(text,textlen,fdbp,cust)
  70. char *text;
  71. int textlen,cust;
  72. fdb *fdbp;
  73. {
  74.   cmxputs("confirm with carriage return");
  75.   return(CMxOK);
  76. }
  77.  
  78.  
  79. /* cfmcplt
  80. **
  81. ** Purpose:
  82. **   Completion for confirmation parse.  We always just beep at the user.
  83. **/
  84.  
  85. PASSEDSTATIC int
  86. cfmcplt(text,textlen,fdbp,full,cplt,cpltlen)
  87. char *text,**cplt;
  88. int textlen,full,*cpltlen;
  89. fdb *fdbp;
  90. {
  91.   *cplt = NULL;                /* no completion text */
  92.   return(CMP_BEL);                /* beep, no wakeup */
  93. }
  94.